import mysql.connector
from mysql.connector import Error
import mysql.connector
def connect_to_mysql():
     connection = mysql.connector.connect(
         host="",  # 例如 'localhost' 或数据库服务器的IP地址
        port="",  # 默认为 3306，除非你的MySQL服务器配置了不同的端口
        user="",  # 你的MySQL用户名
        password="",  # 你的MySQL密码
        database=""  # 你要连接的数据库名
    )
     return connection
def read():
    connection = connect_to_mysql()
    cursor = connection.cursor()
    query = "SELECT * FROM ksxt.tasks"
    cursor.execute(query)
    records = cursor.fetchall()
    return connection,records
if __name__ == '__main__':
    read()